<template>
  <el-card shadow="always" class="login-container">
    <div class="login-container">
      <el-form
          ref="loginFormRef"
          :model="loginForm"
          :rules="loginRules"
          class="login-form"
          status-icon
      >
        <div class="title-container">
          <h3 class="title">系统登录</h3>
        </div>

        <el-form-item prop="username" show-message>
          <el-input
              v-model="loginForm.username"
              clearable
              placeholder="用户名"
              prefix-icon="UserFilled"
              size="large"
              type="text"
          />
        </el-form-item>

        <el-form-item prop="password" show-message>
          <el-input
              :key="formData.passwordType"
              v-model="loginForm.password"
              clearable
              placeholder="密码"
              prefix-icon="Lock"
              show-password
              size="large"
              type="password"
              @keyup.enter.native="handleLogin"
          />
        </el-form-item>

        <el-button :loading="formData.loading" class="login-btn" size="large" type="primary"
                   @click.native.prevent="handleLogin">登 录
        </el-button>

        <div style="position:relative">
          <div class="tips">
            <span>用户名 : admin</span>
            <span>密码 : 123456</span>
          </div>
          <div class="tips">
            <span style="margin-right:18px;">用户名 : editor</span>
            <span>密码 : 123456</span>
          </div>

          <el-button class="social-login" type="primary" @click="handleDialog">
            第三方登录
          </el-button>
        </div>
      </el-form>

      <el-dialog v-model="formData.dialogFormVisible" title="第三方登录" width="30%" center>
        <social-login></social-login>
      </el-dialog>
    </div>
  </el-card>
</template>

<script lang="ts" setup>
import {ref} from 'vue'
import {isPassword, isUsername} from "@/utils/validate/validate"
import SocialLogin from "@/views/login/social/SocialLogin.vue"

const loginForm = ref({
  username: 'admin',
  password: '111111'
})

const loginRules = ref({
  username: [{required: true, trigger: 'blur', validator: isUsername}],
  password: [{required: true, trigger: 'blur', validator: isPassword}]
})

const formData = ref({
  passwordType: 'password',
  capsTooltip: false,
  loading: false,
  dialogFormVisible: false,
  redirect: undefined,
  otherQuery: {}
})

const checkCapslock = () => {

}

const handleLogin = () => {

}

const handleDialog = () => {
  formData.value.dialogFormVisible = true
}
</script>

<style lang="less" scoped>
.login-container {
  min-height: 100%;
  width: 100%;
  background-color: #2d3a4b;
  overflow: hidden;

  .login-form {
    position: relative;
    width: 520px;
    max-width: 100%;
    padding: 160px 35px 0;
    margin: 0 auto;
    overflow: hidden;

    .el-input {
      background: transparent;
      border: 0;
      border-radius: 0;
      color: #fff;
      caret-color: #fff;
    }
  }

  .el-form {
    .el-form-item {
      :deep(*) {
        border: 1px solid rgba(255, 255, 255, 0.1);
        background: rgba(0, 0, 0, 0.1);
        border-radius: 5px;
        color: #454545;
      }
    }
  }

  .el-input {
    :deep(*) {
      background: transparent;
      border: 0;
      border-radius: 0;
      color: #fff;
      caret-color: #fff;
      outline: none;
    }
  }

  .tips {
    font-size: 14px;
    color: #fff;
    margin-bottom: 10px;

    span {
      &:first-of-type {
        margin-right: 16px;
      }
    }
  }

  .title-container {
    position: relative;

    .title {
      font-size: 26px;
      color: #eee;
      margin: 0 auto 40px auto;
      text-align: center;
      font-weight: bold;
    }
  }

  .social-login {
    position: absolute;
    right: 0;
    bottom: 6px;
    background: #409EFF
  }

  .login-btn {
    width: 100%;
    margin-top: 20px;
    margin-bottom: 20px;
  }

}
</style>
